package cn.tedu.charging.order.dao.repository.impl;

import cn.tedu.charging.order.dao.mapper.OrderFailMapper;
import cn.tedu.charging.order.dao.mapper.OrderSuccessMapper;
import cn.tedu.charging.order.dao.repository.OrderRepository;
import cn.tedu.charging.order.pojo.po.ChargingOrderFailPO;
import cn.tedu.charging.order.pojo.po.ChargingOrderSuccessPO;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class OrderRepositoryImpl implements OrderRepository {
    @Autowired
    private OrderSuccessMapper orderSuccessMapper;

    @Autowired
    private OrderFailMapper orderFailMapper;

    public ChargingOrderSuccessPO getSuccessOrder(String orderNo){
        UpdateWrapper updateWrapper = new UpdateWrapper();
        updateWrapper.eq("bill_id",orderNo);
        return orderSuccessMapper.selectOne(updateWrapper);
    }

    public ChargingOrderFailPO getFailOrder(String orderNo){
        UpdateWrapper updateWrapper = new UpdateWrapper();
        updateWrapper.eq("bill_id",orderNo);
        return orderFailMapper.selectOne(updateWrapper);
    }

    @Override
    public Integer saveFailOrder(ChargingOrderFailPO failPO) {
        return orderFailMapper.insert(failPO);
    }


}
